<?php

// +----------------------------------------------------------------------
// | TAODUDU.COM  [ Simple Efficient Excellent ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.taodudu.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: ubten <462193409@qq.com> http://www.ubten.com/
// +----------------------------------------------------------------------

namespace Home\Controller;
use Think\Controller;

class TopicController extends Controller {
    
    function _initialize() {
        addData();
    }
    
    public function aaaa(){
        $sync = M('syncLogin')->select();
        p($sync);
        exit;
        foreach ($sync as $key => $value) {
            $where['user_id'] = $value['uid'];
            $uid = M('users')->where($where)->find();
            if($uid){
                unset($sync[$key]);
            }
        }
        foreach ($sync as $value) {
            p($value['id'].':'.$value['uid']);
        }
    }
    
    
    //put your code here
    public function index(){
        
        $topic_id = I('get.topic_id');
        $map['topic_id'] = $topic_id;
        $topic = M('topic')->where($map)->find();
        $goodList = unserialize($topic['data']);
        foreach ($goodList as $key => $value) {
            foreach ($value as $k => $v) {
                $map['goods_id'] = $v;
                $map['goods_sale'] = 1;
                $a = M('goods')->field('goods_id,goods_title,goods_buytitle,goods_thumb,goods_price,goods_markprice')->where($map)->find();
                if($a != NULL){
                    $goodList[$key][$k] = $a;
                }else{
                    unset($goodList[$key][$k]);
                }
            }
        }
        $this->assign('goodList',$goodList);
        $this->assign('topic',$topic);
        $this->display($topic['template']);
    }
    
    
}
